package com.hans.MessageSend;

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;

import com.hans.myscanner.R;


/**
 * Created by Administrator on 2016/6/30.
 */
public class message extends AppCompatActivity {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_message_send);
    }

    public void sendVc(View v){
        PendingIntent pendingIntent=PendingIntent.getActivity(this,0,new Intent(this,test.class),0);
        final Notification notification=new Notification.Builder(this)
                .setSmallIcon(R.mipmap.ic_launcher)
                .setTicker("收到验证码")
                .setContentTitle("收到记事本发送短信")
                .setContentText("记事本验证码是5555")
                .setContentIntent(pendingIntent).getNotification();//builder（）
        notification.flags=Notification.FLAG_AUTO_CANCEL;

        final NotificationManager manager= (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                manager.notify(100,notification);
            }
        },2000);
    }
}
